<?php
/**
*  Create On 2014-12-29
*  Author yiwei
*  QQ:1006629314
**/
class prepare extends Model{
	private $table = 'xdf_prepare';
	
	public function addPrepare($item_num ,$item_id_str,$period_id){
		$sql = 'INSERT INTO `'.$this->table.'` (`item_num`,`item_id_str`,`period_id`)
				VALUES ('.$item_num.',"'.$item_id_str.'","'.$period_id.'")';
		return $this->insert($sql);
	}
	
	public function getPrepare($id){
		$sql = 'SELECT * FROM `'.$this->table.'` WHERE id = '.$id;
		return $this->fetchRow($sql);
	}
	
	public function modifyPrepare($id,$item_num,$item_id_str){
		$sql = 'UPDATE `'.$this->table.'` 
				SET `item_num` = '.$item_num.',
					`item_id_str` = "'.$item_id_str.'"
				WHERE id = '.$id;
		return $this->update($sql);
	}
	
	public function delPrepare($id){
		$sql = 'DELETE FROM `'.$this->table.'` WHERE id = '.$id;
		return $this->del($sql);
	}
	
	
	public function getPrepareByPeriod($period_id){
		$sql = 'SELECT * FROM `'.$this->table.'` WHERE period_id = '.$period_id;
		return $this->fetchRow($sql);
	}
}